# 作者：徐宇杰
# -*- coding = utf-8 -*-
# @Time :2024/7/11 下午4:00
# @File:__init__.py.py
# @Software:PyCharm
import subprocess
import sys


def install_package(package_name):
    try:
        # 尝试导入包，如果已经安装则不会继续
        __import__(package_name)
        print(f"{package_name} is already installed.")
    except ImportError:
        # 如果包未安装，则使用pip安装
        print(f"{package_name} not found. Installing...")
        subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])


packages = ["numpy", "matplotlib", "tqdm", "requests", "pandas", "openpyxl"]
for package in packages:
    install_package(package)
